home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / pull20.zip / PULLPROC.PAS < prev    next >
Pascal/Delphi Source File  |  1988-01-11  |  8KB  |  241 lines

  1. { =========================================================================== }
  2. { Pullproc.pas - Process procedures for pull-down menus.    ver 2.0, 01-12-87 }
  3. {                                                                             }
  4. { This file contains all the procedures executed by Process.  These are       }
  5. { assigned to any choice in the menus.  They are organized by Main Menu       }
  6. { Pulled (MPulled), Submenu Pulled (SPulled), and Highlighted (HiLited).      }
  7. { (c) 1987,1988 James H. LeMay                                                }
  8. { =========================================================================== }
  9.  
  10. {$R-,S-,I-,D-,T-,F-,V-,B-,N-,L+ }
  11.  
  12. UNIT PullProc;
  13.  
  14. INTERFACE
  15.  
  16. uses
  17.   CRT,PullVars,Pull,PullStat,PullDir;
  18.  
  19. { Your variables for DATA ENTRY TRANSFER go here.  Using CONST will give
  20.   them an initial value. }
  21. const
  22.   aByte:      byte      =    129;
  23.   Seats:      byte      =      4;
  24.   Years:      byte      =     30;
  25.   Month:      byte      =      1;
  26.   Day:        byte      =     12;
  27.   aWord:      word      =  50000;
  28.   aInteger:   integer   = -31456;
  29.   Year:       integer   =   1987;
  30.   PriceLimit: integer   =   2000;
  31.   aLongInt:   longint   = -123456789;
  32.   aReal:      real      = -24.34565E06;
  33.   aHex:       string[4] = 'FF03';
  34.   aChar:      char      = 'Q';
  35.   aString:    MaxString = 'This is a string';
  36.   FileName:   string[12]= 'pulldemo.exe';
  37.   WorkWndwInteger: integer     = 0;
  38.   HexSet:          set of char = ['0'..'9','A'..'F','a'..'f',BSkey];
  39.  
  40. var
  41.   OrigPathName,PathName: string[45];
  42.   FileNameCharSet:       set of char;
  43.  
  44. procedure DataTransfer (VAR ErrMsg: word);
  45. procedure Process (MPulled,SPulled,HiLited: byte);
  46.  
  47.  
  48. IMPLEMENTATION
  49.  
  50. { **************************** DATA ENTRY TRANSFER ************************** }
  51. { ---------------- Set up variables for data windows here: ------------------ }
  52. { Place your variables names here to interface with the menus.  HiLited
  53.   is the selection on that menu that called for the DataWndw.                 }
  54. { Careful! -- there's NO type checking for parameters in Transfer.  You MUST  }
  55. { be certain case statement, DataWndw, and TypeOfData all match.  Be          }
  56. { especially careful of string lenths that are too long.                      }
  57.  
  58. procedure DataTransfer; { (VAR ErrMsg: word); }
  59. var j: word;
  60. begin
  61.   with DataPad do
  62.   begin
  63.     if SPulled=0 then   { SPulled=0 when a Main Menu only is pulled. }
  64.       case MainMenuNames(MPulled) of
  65.         FilesMenu:
  66.            case HiLited of
  67.              1: begin
  68.                   if StoreMode then
  69.                     begin
  70.                       {$I-} ChDir (Sdata); {$I+}
  71.                       if IOresult=0 then
  72.                         begin
  73.                           Transfer (PathName);
  74.                           GetDir (0,PathName);
  75.                         end
  76.                       else ErrMsg:=2;
  77.                     end
  78.                   else
  79.                     begin
  80.                       UserCharSet:=FileNameCharSet + [':','\'];
  81.                       Transfer (PathName);
  82.                     end;
  83.                 end;
  84.              2: begin
  85.                   if StoreMode then
  86.                     begin
  87.                       if Sdata='' then Sdata:='*.*';
  88.                     end
  89.                   else UserCharSet:=FileNameCharSet + ['*','?'];
  90.                   Transfer (FileMask);
  91.                 end;
  92.            end;
  93.         AutoPartsMenu:
  94.            case HiLited of
  95.              3: Transfer (Seats);
  96.            end;
  97.         EnterDataMenu:
  98.            case HiLited of
  99.              1: Transfer (aByte);
  100.              2: Transfer (aWord);
  101.              3: Transfer (aInteger);
  102.              4: Transfer (aLongInt);
  103.              5: Transfer (aReal);
  104.              6: begin
  105.                   Transfer (aHex);
  106.                   if StoreMode then
  107.                     for j:=1 to ord(aHex[0]) do aHex[j]:=upcase(aHex[j])
  108.                   else UserCharSet:=HexSet;
  109.                 end;
  110.              7: Transfer (aChar);
  111.              8: Transfer (aString);
  112.            end;
  113.         OptionsMenu:
  114.            case HiLited of
  115.                  { The following line shows how to place limits on data. }
  116.              7: if StoreMode and ((Idata>2500) or (Idata<=0)) then ErrMsg:=3
  117.                 else Transfer (PriceLimit);
  118.            end;
  119.         IRSmenu:
  120.            case HiLited of
  121.              7: Transfer (Years);
  122.            end;
  123.       end
  124.     else
  125.       case SubMenuNames(SPulled) of
  126.         DateMenu:
  127.            case HiLited of
  128.              1: if StoreMode and ((Bdata=0) or (Bdata>12)) then ErrMsg:=5
  129.                 else Transfer (Month);
  130.              2: if StoreMode and ((Bdata=0) or (Bdata>31)) then ErrMsg:=6
  131.                 else Transfer (Day);
  132.              3: if StoreMode and ((Idata<1960) or (Idata>2010)) then ErrMsg:=7
  133.                 else Transfer (Year);
  134.            end;
  135.       end  { case }
  136.   end  { with }
  137. end;
  138.  
  139. { **************************** PROCESS MENU SELECTION *********************** }
  140. { Place procedures for Process here. }
  141.  
  142. procedure DummyProcess;
  143. begin
  144.   ShowMsg (8);
  145.   Delay (1000)
  146. end;
  147.  
  148. { Place your procedure names here to interface with "Exec-" type menus. }
  149.  
  150. procedure Process; { (MPulled,SPulled,HiLited: byte); }   { LOCAL! }
  151. var LastMsgLineNum: word;
  152. begin
  153.   LastMsgLineNum:=CurrentMsgLineNum;
  154.   if SPulled=0 then   { SPulled=0 when a Main Menu only is pulled. }
  155.     case MainMenuNames(MPulled) of
  156.        FilesMenu:
  157.           case HiLited of
  158.             2: begin
  159.                  PullDown:=true;
  160.                  MoreCmdSeq:='D';
  161.                end;
  162.             3: PullDirectory (FileName,'');
  163.                { use (FileName,FileName) to initially Hilite a close match }
  164.            end;
  165.        UtilitiesMenu:
  166.           case HiLited of
  167.             1..7: DummyProcess;
  168.           end;
  169.        IRSmenu:
  170.           case HiLited of
  171.             6: ;
  172.             2..7: DummyProcess;
  173.           end;
  174.        QuitMenu:
  175.           case HiLited of
  176.             2: begin
  177.                  PopToWorkWndw:=true;
  178.                  Quit:=true
  179.                end;
  180.           end;
  181.     end
  182.   else
  183.     case SubMenuNames(SPulled) of
  184.       UpdateMenu:
  185.          case HiLited of
  186.            1: DummyProcess;
  187.            2: begin
  188.                { The following line are how you process first and then pop
  189.                  the menu. }
  190.                 DummyProcess;
  191.                 PopToWorkWndw:=true
  192.               end;
  193.            3:  { The following line is how you pop the menus first and
  194.                  then process. }
  195.               if Popped then DummyProcess;
  196.            4: begin
  197.                { The following lines are how you pop the menus first,
  198.                  process, and then pull the same menu(s) again which is good
  199.                  for updating the work window. }
  200.                 if Popped then DummyProcess;
  201.                 PullDown:=true
  202.               end;
  203.            5: begin
  204.                { The following lines are how you pop by a number of levels
  205.                  so that part of the menus will remain displayed while
  206.                  going to another submenu. }
  207.                 PopLevels:=1;
  208.                 PullDown:=true;
  209.                 MoreCmdSeq:='Y'
  210.               end;
  211.            6: begin
  212.                { The following lines are how you go to a completely
  213.                  different menu. }
  214.                 PopToTop:=true;
  215.                 PullDown:=true;
  216.                 MoreCmdSeq:='AR'
  217.               end;
  218.          end;
  219.         { The following is how to enter a sequence of entries. }
  220.       DateMenu:
  221.          case HiLited of
  222.            1: begin
  223.                 PullDown:=true;
  224.                 MoreCmdSeq:='D'
  225.               end;
  226.            2: begin
  227.                 PullDown:=true;
  228.                 MoreCmdSeq:='Y'
  229.               end;
  230.            3: PopLevels:=1;
  231.          end;
  232.     end;  { case }
  233.   if not(PopToWorkWndw or PopToTop or (PopLevels>0) or PullDown) then
  234.     ShowMsg (LastMsgLineNum);
  235. end;
  236.  
  237. BEGIN
  238.   AddrDataTransfer:=@DataTransfer;
  239.   AddrProcess     :=@Process;
  240. END.